package com.idata.model.enums;

import lombok.Getter;

import java.util.Objects;
import java.util.stream.Stream;

/**
 * @File StatisticsCase.Java
 * @Modify Time      @Author    @Version    @Description
 * ------------      -------    --------    -----------
 * 2023/10/13         yd.j      1.0         None
 */
@Getter
public enum StatisticsTypeForInputEnum {
    SUM("纠纷总数", 0),
    
    POLICE("警情数量", 1),
    CASE("案件数量", 2),

    HIGH_RISK("高危纠纷", 3),
    ;


    private final String name;

    private final int code;


    StatisticsTypeForInputEnum(String name, int code) {
        this.name = name;
        this.code = code;
    }

    public static StatisticsTypeForInputEnum of(String name) {
        Objects.requireNonNull(name);

        return Stream.of(values()).filter(bean -> bean.name.equals(name)).findAny().orElseThrow(() -> new IllegalArgumentException(name + " not exists!"));
    }

    public static StatisticsTypeForInputEnum of(int code) {

        return Stream.of(values()).filter(bean -> bean.code == code).findAny().orElseThrow(() -> new IllegalArgumentException(code + " not exists!"));
    }
}
